package cn.levi.excel.configuration;

import cn.levi.excel.DefaultExcellDictContextHolder;
import cn.levi.excel.ExcellDictContextHolder;
import cn.levi.excel.validate.ValidateDate;
import cn.levi.excel.validate.ValidateLength;
import cn.levi.excel.validate.ValidateNumber;
import cn.levi.excel.validate.ValidateRequired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * excell校验的自动配置类
 *
 * @author lei
 * @since 2024/11/11
 */
@Configuration
@Import(ExcellProperties.class)
public class ExcellValidateAutoConfiguration {


	@Bean
	@ConditionalOnMissingBean()
	public ValidateDate getValidateDate() {
		return new ValidateDate();
	}
	@Bean
	@ConditionalOnMissingBean()
	public ValidateLength getValidateLength() {
		return new ValidateLength();
	}
	@Bean
	@ConditionalOnMissingBean()
	public ValidateNumber getValidateNumber() {
		return new ValidateNumber();
	}
	@Bean
	@ConditionalOnMissingBean()
	public ValidateRequired getValidateRequired() {
		return new ValidateRequired();
	}
	@Bean
	@ConditionalOnMissingBean(ExcellDictContextHolder.class)
	public ExcellDictContextHolder getExcellDictContextHolder() {
		return new DefaultExcellDictContextHolder();
	}
}
